#5171 closed defect (fixed)
SELECT st_length(st_geomfromtext gives error when running on Proj 6.3 when points input are the same
Reported by: | arnghosb | Owned by: | pramsey |
---|---|---|---|
Priority: | high | Milestone: | PostGIS 2.5.8 |
Component: | postgis | Version: | 3.2.x |
Keywords: | Cc: | arnghosb |
Description
SELECT st_length(st_geomfromtext('LINESTRING(-86.848960876 33.448753357,-86.848960876 33.448753357)',4326)::geography); returns ERROR: lwgeom_length_spheroid returned length < 0.0 on ARM (aarch64/Graviton) processor. On Intel processor, it returns the correct output (0.0). Notice that here, the points input are the same, so technically, it should return 0.
Change History (22)
comment:1 by , 3 years ago
Summary: | SELECT st_length(st_geomfromtext gives error when running on ARM processor → SELECT st_length(st_geomfromtext gives error when running on ARM processor when points input are the same |
---|
comment:2 by , 3 years ago
comment:3 by , 3 years ago
Okay I was able to replicate the issue on my Amazon RDS instance
That is running:
POSTGIS="3.1.5 0" [EXTENSION] PGSQL="130" GEOS="3.9.1dev-CAPI-1.14.1" PROJ="6.2.1" GDAL="GDAL 2.3.1, released 2018/06/22" LIBXML="2.9.9" LIBJSON="0.12.99" LIBPROTOBUF="1.3.0" WAGYU="0.5.0 (Internal)" TOPOLOGY RASTER PostgreSQL 13.6 on aarch64-unknown-linux-gnu, compiled by aarch64-unknown-linux-gnu-gcc (GCC) 7.4.0, 64-bit
comment:4 by , 3 years ago
Milestone: | PostGIS 3.2.2 → PostGIS 3.1.6 |
---|
comment:5 by , 3 years ago
This is the output for the version: POSTGIS="3.2.1 0" [EXTENSION] PGSQL="140" GEOS="3.9.1dev-CAPI-1.14.1" PROJ="6.2.1" LIBXML="2.9.9" LIBJSON="0.12.99" LIBPROTOBUF="1.3.0" WAGYU="0.5.0 (Internal)" PostgreSQL 14.3 on aarch64-u nknown-linux-gnu, compiled by aarch64-unknown-linux-gnu-gcc (GCC) 7.4.0, 64-bit
comment:6 by , 3 years ago
Thanks. I'll try 3.2.1 next to see if I can replicate. Might be a GCC bug issue is another thought as I'm running a newer GCC on my ARM.
comment:8 by , 3 years ago
Ah I think you are right. My earlier test where I was able to replicate the issue was on Amazon Aurora, not RDS.
On RDS the test is fine — my AMZ RDS is running below, a newer proj
POSTGIS="3.1.4 ded6c34" [EXTENSION] PGSQL="140" GEOS="3.9.1-CAPI-1.14.2" PROJ="8.0.1" GDAL="GDAL 3.3.0, released 2021/04/26" LIBXML="2.9.1" LIBJSON="0.15" LIBPROTOBUF="1.3.2" WAGYU="0.5.0 (Internal)" RASTER PostgreSQL 14.1 on aarch64-unknown-linux-gnu, compiled by gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-6), 64-bit
comment:9 by , 2 years ago
Milestone: | PostGIS 3.1.6 → PostGIS 3.1.7 |
---|---|
Summary: | SELECT st_length(st_geomfromtext gives error when running on ARM processor when points input are the same → SELECT st_length(st_geomfromtext gives error when running on Proj 6.3 when points input are the same |
I think this is a bug with Proj as it's only replicable on proj 6.3.2 and so probably doesn't have anything to do with ARM. arnghosb suggested maybe we go thru the same path as we do for lower geometry. Anyway pushing this off.
comment:11 by , 2 years ago
No great clues in blame. Only two commits in the geod_inverse function, a couple months ago (way more recent than proj 6.2.1):
https://github.com/OSGeo/PROJ/commit/39bb04beba6357a0374fcdb31ee406293a722bf4
And in 2016 (way earlier than 6.2.1)
https://github.com/OSGeo/PROJ/commit/16df65976714747f2ab5fb73a47327970ccd723f#
comment:12 by , 2 years ago
But it's 6.3.2 we are talking about. Could the issue have been introduced later.
comment:13 by , 2 years ago
How much do we truly care? Are we going to submit an upstream patch for a 5-years-out-of-date proj?
comment:14 by , 2 years ago
No no need to report to PROJ. I think the question was can we do similar to what we are doing with the non-geoid path that for linestrings where points are the same just return 0, do we need to error at all?
comment:15 by , 2 years ago
For clarification, what Arnab was pointing out to me, didn't realize it wasn't on this ticket.
Was that he saw this line:
https://github.com/postgis/postgis/blob/3.2.1/liblwgeom/lwspheroid.c#L202-L205
But it is only done for the non-geographic lib loop. Why can't it be done for the other loop as well.
comment:21 by , 2 years ago
Milestone: | PostGIS 3.1.7 → PostGIS 2.5.9 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
I assume this is done, as branches 2.5-3.3 have the commit
comment:22 by , 2 years ago
Milestone: | PostGIS 2.5.9 → PostGIS 2.5.8 |
---|
Can you output what
Testing on my ARM, I get 0 for answer as expected.
I'm running:
I'll try to install PostGIS 3.2 to see if it's an issue there.